<template>
  <div class="article-management">
    <h2>文章管理</h2>
    <div class="operation-bar">
      <el-button type="primary" @click="handleAdd">新增文章</el-button>
      <el-input
        v-model="searchKeyword"
        placeholder="搜索文章标题"
        style="width: 200px; margin-left: 10px"
      />
    </div>
    
    <el-table :data="articles" style="width: 100%">
      <el-table-column prop="id" label="ID" width="80" />
      <el-table-column prop="title" label="标题" />
      <el-table-column prop="category" label="分类" />
      <el-table-column prop="author" label="作者" />
      <el-table-column prop="createTime" label="创建时间" />
      <el-table-column prop="status" label="状态">
        <template #default="scope">
          <el-tag :type="scope.row.status === '已发布' ? 'success' : 'info'">
            {{ scope.row.status }}
          </el-tag>
        </template>
      </el-table-column>
      <el-table-column label="操作" width="200">
        <template #default="scope">
          <el-button size="small" @click="handleEdit(scope.row)">编辑</el-button>
          <el-button size="small" type="danger" @click="handleDelete(scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script setup>
import { ref } from 'vue'

const searchKeyword = ref('')

const articles = ref([
  {
    id: 1,
    title: 'Vue3 新特性介绍',
    category: '前端开发',
    author: '张三',
    createTime: '2024-03-20',
    status: '已发布'
  },
  {
    id: 2,
    title: 'Element Plus 使用指南',
    category: 'UI框架',
    author: '李四',
    createTime: '2024-03-19',
    status: '草稿'
  }
])

const handleAdd = () => {
  // TODO: 实现新增文章逻辑
}

const handleEdit = (row) => {
  // TODO: 实现编辑文章逻辑
}

const handleDelete = (row) => {
  // TODO: 实现删除文章逻辑
}
</script>

<style scoped>
.article-management {
  padding: 20px;
}

.operation-bar {
  margin-bottom: 20px;
  display: flex;
  align-items: center;
}
</style> 